package com.changgou.listener;

import com.changgou.search.service.EsManagerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author BAO
 * @version V1.0
 * @Package com.changgou.listener
 * @date 2020/12/9 20:24
 * @description:
 */
@RabbitListener(queues = {"search_add_queue"})
@Component
public class SpuAddListener {
    private static final Logger logger = LoggerFactory.getLogger(SpuAddListener.class);
    @Autowired
    private EsManagerService esManagerService;

    @RabbitHandler
    public void addDataToES(String spuId){
        logger.info("spuId={}",spuId);
        esManagerService.importDataToESBySpuId(spuId);
    }
}
